home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 406_01 / atoc / labels.c < prev    next >
Text File  |  1993-11-09  |  1KB  |  47 lines

  1. /*=========================================================================
  2.  
  3.     ATOC labels module
  4.  
  5. =========================================================================*/
  6.  
  7. #include <stdio.h>
  8. #include <ctype.h>
  9. #include "atoc.h"
  10.  
  11.  
  12. /*-------------------------------------------------------------------------
  13. labels( s ) searches for goto labels, and makes sure they carry a statement
  14. on the same line.
  15. -------------------------------------------------------------------------*/
  16. labels( s )
  17. char *s;
  18. {
  19.     char *cp, *strchr();
  20.  
  21.     if ( strchr( s, ':' ) != NULL )
  22.     {
  23.         /* find first non-whitespace character on line */
  24.         for ( cp = s; *cp && isspace( *cp ); ++cp )
  25.             ;
  26.         if ( isid( *cp ) )
  27.             if ( strncmp( cp, "default", 7 ) != 0 )
  28.             {
  29.                 /* bypass possible label */
  30.                 for ( ; *cp && isid( *cp ); ++cp )
  31.                     ;
  32.                 /* bypass possible whitespace after label */
  33.                 for ( ; *cp && isspace( *cp ); ++cp )
  34.                     ;
  35.                 /* MUST be colon - can't be another identifier, etc. */
  36.                 if ( *cp == ':' )
  37.                 {
  38.                     for ( ++cp; *cp; ++cp )
  39.                         if ( ! isspace( *cp ) )
  40.                             return;
  41.                     strcat( s, " ;" ); /* make null statement */
  42.                 }
  43.             }
  44.     }
  45. }
  46. /*=======================================================================*/
  47.